package cn.edu.javaweb.superServlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.javaweb.utils.DBUtil;

@WebServlet("/AddExamine")
public class AddExamine extends HttpServlet {
	 DBUtil db; //声明对象 一定要赋值  否则空指针异常
	 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 db=new DBUtil(); //建创对象 搭桥配置初始化
			String id=request.getParameter("id");
			String sql="update examine set state=0 where id='"+id+"'";
			System.out.println(sql);
			String name=request.getParameter("name");
			String tel=request.getParameter("telephone");
			String sex=request.getParameter("sex");
			String password=request.getParameter("password");
			String uclass=request.getParameter("uclass");
			String add="insert into user(username,password,uclass,sex,tel,ident) values('"+name+"','"+password+"','"+uclass+"','"+sex+"','"+tel+"',1)";
			System.out.println(add);
			int result=db.update(sql);
			int result09=db.update(add);
			PrintWriter out=response.getWriter();
			response.sendRedirect("/Volunteer/SelectExamine");
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response); 
	}

}
